import React, {Component} from 'react';
import {StackNavigator, TabNavigator, TabBarBottom} from 'react-navigation';
import PhoneLoginScreen from '../screen/PhoneLoginScreen'
import LoginScreen from '../screen/LoginScreen'
import HomeScreen from '../screen/HomeScreen'
import TalentScreen from '../screen/TalentScreen'
import DiscoverScreen from '../screen/DiscoverScreen'
import MessageScreen from '../screen/MessageScreen'
import MeScreen from '../screen/MeScreen'
import TabBarItem from '../../component/TabBarItem'
import GlobalStyles from '../../res/styles/GlobalStyles';

export default class NavManager extends Component {
    render() {
        return (<Nav/>);
    }
    componentDidMount() {
        if (!__DEV__) {
            global.console = {
                info: () => {},
                log: () => {},
                warn: () => {},
                error: () => {}
            }
        };
    };
}

const MainTab = TabNavigator({
    Home: {
        screen: HomeScreen,
        navigationOptions: ({navigation}) => ({
            title: '首页',
            tabBarIcon: ({focused, tintColor}) => (<TabBarItem
                tintColor={tintColor}
                focused={focused}
                normalImage={require('../../res/img/ic_home.png')}
                selectedImage={require('../../res/img/ic_home.png')}/>)
        })
    },
    Talent: {
        screen: TalentScreen,
        navigationOptions: ({navigation}) => ({
            title: '人才',
            tabBarIcon: ({focused, tintColor}) => (<TabBarItem
                tintColor={tintColor}
                focused={focused}
                normalImage={require('../../res/img/ic_talent.png')}
                selectedImage={require('../../res/img/ic_talent.png')}/>)
        })
    },
    Discovr: {
        screen: DiscoverScreen,
        navigationOptions: ({navigation}) => ({
            title: '发现',
            tabBarIcon: ({focused, tintColor}) => (<TabBarItem
                tintColor={tintColor}
                focused={focused}
                normalImage={require('../../res/img/ic_discover.png')}
                selectedImage={require('../../res/img/ic_discover.png')}/>)
        })
    },
    Message: {
        screen: MessageScreen,
        navigationOptions: ({navigation}) => ({
            title: '消息',
            tabBarIcon: ({focused, tintColor}) => (<TabBarItem
                tintColor={tintColor}
                focused={focused}
                normalImage={require('../../res/img/ic_message.png')}
                selectedImage={require('../../res/img/ic_message.png')}/>)
        })
    },
    Me: {
        screen: MeScreen,
        navigationOptions: ({navigation}) => ({
            title: '我的',
            tabBarIcon: ({focused, tintColor}) => (<TabBarItem
                tintColor={tintColor}
                focused={focused}
                normalImage={require('../../res/img/ic_me.png')}
                selectedImage={require('../../res/img/ic_me.png')}/>)

        })
    }

}, {
    lazy: true,
    tabBarComponent: TabBarBottom,
    tabBarPosition: 'bottom',
    swipeEnabled: false,
    animationEnabled: false,
    headerTitleStyle: {
        justifyContent: 'center'
    },
    tabBarOptions: {
        showIcon: true,
        scrollEnabled: false
    }
})

const Nav = StackNavigator({
    Login: {
        screen: LoginScreen,
        navigationOptions: {
            header: null
        }
    },
    PhoneLogin: {
        screen: PhoneLoginScreen,
        navigationOptions: {
            headerTitle: "手机号登录"
        }
    },
    MainTab: {
        screen: MainTab,
        navigationOptions: {
            headerBackTitle: null,
            headerLeft: null
        }
    }
}, {initialRouteName: 'Login'});